#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "sys/ioctl.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"
#include <poll.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <fcntl.h>

#define REG_CMD  0x40
#define REG_DATA 0x00

#define CMD_IOC_MAGIC	'a'
#define CMD_CLEAR		_IOW(CMD_IOC_MAGIC, 0,int)

typedef unsigned char u8;

u8 OLED_GRAM[8][128];/*定义OLED显存数组*/

/*
 * @description		: main主程序
 * @param - argc 	: argv数组元素个数
 * @param - argv 	: 具体参数
 * @return 			: 0 成功;其他 失败
 */
int main(int argc, char *argv[])
{
	int fd;
	int cmd;
	int ret;
	char *filename;
	unsigned short databuf[3];
	unsigned short ir, als, ps;

	if (argc != 2) {
		printf("Error Usage!\r\n");
		return -1;
	}

	filename = argv[1];
	fd = open(filename, O_RDWR);
	if(fd < 0) {
		printf("can't open file %s\r\n", filename);
		return -1;
	}
	
	while(1)
	{
		printf("Please input cmd:");
		scanf("%d",&cmd);
		getchar();
		if(cmd == -1)
			break;
		ret = ioctl(fd,CMD_CLEAR,cmd);
		printf("ret:%d\n",ret);
		if(ret<0)
			break;
	}
	// ret = ioctl(fd,CMD_CLEAR,0xFF);

	close(fd);	/* 关闭文件 */	
	return 0;
}

